<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>按钮</title>
    <style>
        *{margin: 0;padding: 0;list-style-type: none;}
        .wrap{
            height: 60px;
            width: 200px;
            background: skyblue;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="wrap" id="box">按钮</div>
    <script>
        let tmp = document.getElementById("box"),
            colorArr = ["skyblue","green"],
            num = 0;
        tmp.onclick = function(){
            num++;
            console.log(num);
            tmp.style.backgroundColor = colorArr[num%2];
        }
    </script>
</body>
</html>